package com.yuexunit.mobilenurse.module.SkinTest.adapter;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.TextView;

import com.yuexunit.mobilenurse.R;
import com.yuexunit.mobilenurse.module.SkinTest.bean.SkinTestListBean;
import com.yuexunit.mobilenurse.module.SkinTest.ui.Act_SkinTest_Detail;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.Collection;

/**
 * Created by work-jx on 2015/12/9.
 */
public class SkinTestNewAdapter extends KJAdapter<SkinTestListBean> {

    public SkinTestNewAdapter(AbsListView view, Collection mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(AdapterHolder adapterHolder, SkinTestListBean skinTestListBean, boolean b) {
        TextView testlist_item_statu = (TextView)adapterHolder.getView(R.id.testlist_item_statu);
        ImageView ic_arrow = (ImageView)adapterHolder.getView(R.id.ic_arrow);
        adapterHolder.setText(R.id.testlist_item_name,skinTestListBean.getPsmc());
        adapterHolder.setText(R.id.testlist_item_num,"皮试号:"+skinTestListBean.getPsh());
//        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd",java.util.Locale.getDefault());
//        Date curDate = injectionList_exreqlist.getEntrytime();
//        String str= formatter.format(curDate);
        adapterHolder.setText(R.id.testlist_item_data,"开单时间:"+skinTestListBean.getTime());
        adapterHolder.setText(R.id.testlist_item_statu, skinTestListBean.getPszt());
//        if(skinTestListBean.getPszt().equals("0"))
//        {
//            adapterHolder.setText(R.id.testlist_item_statu, "未皮试");
//        }
//        else if(skinTestListBean.getPszt().equals("1")){
//            adapterHolder.setText(R.id.testlist_item_statu, "已皮试");
//        }


        onPicClick(adapterHolder.getConvertView(), skinTestListBean.getPsh());
    }

    private void onPicClick(View view,final String Requestno) {
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    Bundle bundle = new Bundle();
                    bundle.putString("psh", Requestno);
                    Intent intent = new Intent(mCxt, Act_SkinTest_Detail.class);
                    intent.putExtras(bundle);
                    mCxt.startActivity(intent);
            }
        });
    }
}
